from typing import List


class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next


def node2list(head: ListNode) -> List:
    ret = []
    while head is not None:
        ret.append(head.val)
        head = head.next
    return ret


def list2Node(lst: List) -> ListNode:
    head = node = ListNode()
    for i in lst:
        node.next = ListNode(i)
        node = node.next
    return head.next
